<?php

namespace app\controller\system;

use app\controller\BaseController;
use app\model\system\SysLog;
use support\Request;
use support\Response;

class LogController extends BaseController
{
    public function delete(Request $request, int $id): Response
    {
        return $this->success([]);
    }

    public function page(Request $request): Response
    {
        $pageSize = $request->get("pageSize", 20);
        $pageNum = $request->get("pageNum", 1);
        $list = SysLog::order("id", "desc")->paginate(['list_rows' => $pageSize, 'page' => $pageNum]);
        $total = $list->total();
        return $this->success(["list" => $list->items(), "total" => $total]);
    }

    public function visitTrend(Request $request): Response
    {
        $startDate = $request->get('startDate');
        $endDate = $request->get('endDate');
        return $this->success(["dates" => [$startDate, $endDate], "pvList" => [], "ipList" => []]);
    }

    public function visitStatus(): Response
    {
        $retArray = [
            "todayUvCount" => 0,
            "totalUvCount" => 0,
            "uvGrowthRate" => 0,
            "todayPvCount" => 0,
            "totalPvCount" => 0,
            "pvGrowthRate" => 0
        ];
        return $this->success($retArray);
    }
}
